from selenium.webdriver.common.by import By

from Driver.Driver import MDriver
from part import BarFace
class PersonalPost:
    driver=''
    def __init__(self):
        self.driver=MDriver.driver
    # 进入个人帖子集合界面
    def Come(self):
        BarFace.BarFace().Come()
        BarFace.BarFace().BarHead()
        BarFace.BarFace().BarGotoPersonalPost()
    # 方便写代码
    def QFind(self,name):
        self.driver.find_element(By.CSS_SELECTOR,name)
    # 检测界面元素
    def PersonalPostFace(self):
        # 检测头像
        self.QFind("#profile_avatar")
        # 检测姓名
        self.QFind("#profile_nickname")
        # 检测发帖数
        self.QFind("#bit-forum-content > div.page-header.d-print-none > div > div > div.col > div > div:nth-child(1)")
        # 检测邮箱
        self.QFind("#bit-forum-content > div.page-header.d-print-none > div > div > div.col > div > div:nth-child(2)")
        # 检测注册日期
        self.QFind("#bit-forum-content > div.page-header.d-print-none > div > div > div.col > div > div:nth-child(3)")
        # 检测个人介绍
        self.QFind("#bit-forum-content > div.page-body > div > div > div.col-lg-4 > div > div > div > div > h2")
        self.QFind("#profile_remark")
        # 检测帖子前的一个图标
        self.QFind("#profile_article_body > li:nth-child(1) > div.timeline-event-icon.bg-twitter-lt")
        # 检测帖子标题
        self.QFind("#profile_article_body > li:nth-child(1) > div.card.timeline-event-card > div > div > div > div > div.text-truncate")
        # 检测帖子发布时间
        self.QFind("#profile_article_body > li:nth-child(1) > div.card.timeline-event-card > div > div > div > div > div.text-muted.mt-2 > div > div.col > ul > li")
        # 检测帖子观看量
        self.QFind("#profile_article_body > li:nth-child(1) > div.card.timeline-event-card > div > div > div > div > div.text-muted.mt-2 > div > div.col-auto.d-none.d-md-inline > ul > li:nth-child(1)")
        # 检测帖子点赞量
        self.QFind("#profile_article_body > li:nth-child(1) > div.card.timeline-event-card > div > div > div > div > div.text-muted.mt-2 > div > div.col-auto.d-none.d-md-inline > ul > li:nth-child(2)")
        # 检测帖子评论量
        self.QFind("#profile_article_body > li:nth-child(1) > div.card.timeline-event-card > div > div > div > div > div.text-muted.mt-2 > div > div.col-auto.d-none.d-md-inline > ul > li:nth-child(3)")

    # 打开帖子
    def PersonalPostOpenPost(self):
        self.driver.find_element(By.CSS_SELECTOR,"#profile_article_body > li:nth-child(1) > div.card.timeline-event-card > div > div > div > div > div.text-truncate > a > strong").click()

